import pandas as pd

base_filename = "clsbb_clsbbfak_records20230911"
csv_path = f"D:\开发需求\七库全书\批量导入\{base_filename}.csv"
sql_path = f"D:\开发需求\七库全书\批量导入\{base_filename}.sql"
# table_name = "clsbb_clsbb_common_pdfs"
table_name = "clsbb_clsbbfak_records"

data = pd.read_csv(csv_path)

sql_lines = []
for index, row in data.iterrows():
    values = ", ".join([f"NULL" if pd.isnull(i) else f"'{str(i)}'" for i in row])
    sql_line = f"INSERT INTO {table_name} VALUES ({values});"
    sql_lines.append(sql_line)

with open(sql_path, "w") as f:
    for line in sql_lines:
        f.write("%s\n" % line)
